package com.test.tinyurl.util;

import com.test.tinyurl.common.Constant;

import java.util.HashMap;
import java.util.Map;

public class ResponseUtil {

    /**
     * 自定义返回格式
     *
     * @param count
     * @param data
     * @param conditions
     * @return
     */
    public static Map<String, Object> defaultResponse(Object count,
                                                      Object data,
                                                      Object conditions) {
        Map<String, Object> maps = new HashMap<>(5);
        maps.put(Constant.RESPONSE_CODE, Constant.SUCCESS_CODE);
        maps.put(Constant.RESPONSE_MSG, Constant.DEFAULT_SUCCESS_MSG);
        maps.put(Constant.RESPONSE_COUNT, count);
        maps.put(Constant.RESPONSE_DATA, data);
        maps.put(Constant.RESPONSE_CONDITION, conditions);
        return maps;
    }


    /**
     * 自定义返回格式
     *
     * @param code
     * @param msg
     * @param count
     * @param data
     * @param conditions
     * @return
     */
    public static Map<String, Object> defaultResponse(String code,
                                                      String msg,
                                                      Object count,
                                                      Object data,
                                                      Object conditions) {
        Map<String, Object> maps = new HashMap<>(5);
        maps.put(Constant.RESPONSE_CODE, code);
        maps.put(Constant.RESPONSE_MSG, msg);
        maps.put(Constant.RESPONSE_COUNT, count);
        maps.put(Constant.RESPONSE_DATA, data);
        maps.put(Constant.RESPONSE_CONDITION, conditions);
        return maps;
    }
}
